﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public partial class admin_ManageUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            BindDataGrid(1);

        }
        else
        {

        }
    }
    #region Bind data to grid
    protected void BindDataGrid(int pageIndex)
    {
        try
        {
            grdMember.DataSource = User_Session.GetList_User();
            grdMember.DataBind();	
        }
        catch (Exception ex)
        {
            //throw ex;
        }

    }
    #endregion

    protected void grdMember_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdMember.PageIndex = e.NewPageIndex;
        BindDataGrid(grdMember.PageIndex);
    }
    protected void grdMember_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        string strUserID = e.CommandArgument.ToString().Trim();
        string strCommand = e.CommandName;
        switch (strCommand)
        {

            case "delete_User":
                try
                {

                    User user = User_Session.Get_User_ByID(int.Parse(strUserID));
                    if (user == null) return;
                    User_Session.Delete_User(user);
                    //xoa cho nay di
                    WebMsgBox.Show("Đã xóa thành công");
                    BindDataGrid(1);
                }
                catch (Exception ex)
                {
                    //throw ex;
                }
                break;
        }
    }
}
